package com.cskaoyan.service;

import com.cskaoyan.bean.User;
import com.cskaoyan.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author stone
 * @date 2022/04/30 10:05
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    UserMapper userMapper;

    @Override
    public void add(User user) {
        user.setCreateDate(new Date());
        int i = userMapper.insertUser(user);

    }

    @Override
    public List<User> query(String username) {
        username = "%" + username + "%";

        return userMapper.selectByUsername(username);
    }

    @Override
    public User query(String username, String password) {
        return userMapper.selectByUsernameAndPassword(username, password);
    }

    @Override
    public User queryByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }
}
